<template>
  <div class="seven_content myStyle">
    <div class="content_top">
      <StrokeTitle title="数据统计" class="float margin" style="width: 99%" :isCenter="true">
        <div class="flex_center">
          <div class="bzjk_box flex_between">
            <!-- <div class="sjtj_item backgroung flex_between_direction">
              <div class="title flex_center" :class="'text_' + color[0]">
                内控值
              </div>
              <div class="number flex_center" :class="['text_shadow_' + color[0], 'border_' + color[0]]">
                {{ top[0] + "%" }}
              </div>
            </div>
            <img src="@/assets/images/echarts/zu2.png" alt="" class="and" />
            <div class="sjtj_item backgroung flex_between_direction">
              <div class="title flex_center" :class="'text_' + color[1]">
                当月数值
              </div>
              <div class="number flex_between" :class="['text_shadow_' + color[1]]">
                <div class="bottom-item" :class="['border_' + color[1]]">
                  {{ top[1] + "%" }}
                </div>
                 <div class="bottom-item" :class="['border_' + color[1]]">
                  {{ top[1] + "%" }}
                </div>
              </div>
            </div>
            <img src="@/assets/images/echarts/zu2.png" alt="" class="and" />
            <div class="sjtj_item backgroung flex_between_direction">
              <div class="title flex_center" :class="'text_' + color[2]">
                当季数值
              </div>
              <div class="number flex_center" :class="['text_shadow_' + color[2], 'border_' + color[2]]">
                {{ top[2] + "%"||'' }}
              </div>
            </div>
            <img src="@/assets/images/echarts/zu2.png" alt="" class="and" />
            <div class="sjtj_item backgroung flex_between_direction">
              <div class="title flex_center" :class="'text_' + color[3]">
                当年数值
              </div>
              <div class="number flex_center" :class="['text_shadow_' + color[3], 'border_' + color[3]]">
                {{ top[3] + "%" }}
              </div>
            </div> -->
            <!-- <img src="@/assets/images/echarts/zu2.png" alt="" class="and" />
            <div class="sjtj_item backgroung flex_between_direction">
              <div class="title flex_center" :class="'text_' + color[4]">
                整体均值
              </div>
              <div class="number flex_center" :class="['text_shadow_' + color[4], 'border_' + color[4]]">
                {{ top[4] + "%" }}
              </div>
            </div> -->
            <div class="cntj_item backgroung">
              <nav class="flex_center" :class="'text_' + color[0]">
                当月内控标准
              </nav>
              <div class="cntj_item_content flex_between">
                <div class="cntj_item_content_item flex_center_direction cntj_item_content_item" :class="['border_' + color[0]] ">
                  <div class="number" :class="'text_shadow_' + color[0]">
                    {{ top [0] + "‱" }}
                    <!-- ‱ -->
                  </div>
                  <div class="unit" style="position:relative;top:-5px">客户投诉率</div>
                </div>
                <div class="cntj_item_content_item flex_center_direction cntj_item_content_item" :class="['border_' + color[0]] ">
                  <div class="number" :class="'text_shadow_' + color[0]">
                    {{ top1[0] + "%" }}
                  </div>
                  <div class="unit">制程合格率</div>
                </div>

              </div>
            </div>
            <img src="@/assets/images/echarts/zu2.png" alt="" class="and" />
            <div class="cntj_item backgroung">
              <nav class="flex_center" :class="'text_' + color[0]">
                当月数据
              </nav>
              <div class="cntj_item_content flex_between">
                <div class="cntj_item_content_item flex_center_direction cntj_item_content_item" :class="['border_' + color[1]] ">
                  <div class="number" :class="'text_shadow_' + color[1]">
                    {{ top[1] + "‱" }}
                  </div>
                  <div class="unit" style="position:relative;top:-5px">客户投诉率</div>
                </div>
                <div class="cntj_item_content_item flex_center_direction cntj_item_content_item" :class="['border_' + color[1]] ">
                  <div class="number" :class="'text_shadow_' + color[1]">
                    {{ top1[1] + "%" }}
                  </div>
                  <div class="unit">制程合格率</div>
                </div>

              </div>
            </div>
            <img src="@/assets/images/echarts/zu2.png" alt="" class="and" />
            <div class="cntj_item backgroung">
              <nav class="flex_center" :class="'text_' + color[0]">
                当季数据
              </nav>
              <div class="cntj_item_content flex_between">
                <div class="cntj_item_content_item flex_center_direction cntj_item_content_item" :class="['border_' + color[2]] ">
                  <div class="number" :class="'text_shadow_' + color[2]">
                    {{ top[2] + "‱" }}
                  </div>
                  <div class="unit" style="position:relative;top:-5px">客户投诉率</div>
                </div>
                <div class="cntj_item_content_item flex_center_direction cntj_item_content_item" :class="['border_' + color[2]] ">
                  <div class="number" :class="'text_shadow_' + color[2]">
                    {{ top1[2] + "%" }}
                  </div>
                  <div class="unit">制程合格率</div>
                </div>
              </div>
            </div>
            <img src="@/assets/images/echarts/zu2.png" alt="" class="and" />
            <div class="cntj_item backgroung">
              <nav class="flex_center" :class="'text_' + color[3]">
                当年数据
              </nav>
              <div class="cntj_item_content flex_between">
                <div class="cntj_item_content_item flex_center_direction cntj_item_content_item" :class="['border_' + color[3]] ">
                  <div class="number" :class="'text_shadow_' + color[3]">
                    {{ top[3] + "‱" }}
                  </div>
                  <div class="unit" style="position:relative;top:-5px">客户投诉率</div>
                </div>
                <div class="cntj_item_content_item flex_center_direction cntj_item_content_item" :class="['border_' + color[3]] ">
                  <div class="number" :class="'text_shadow_' + color[3]">
                    {{ top1[3] + "%" }}
                  </div>
                  <div class="unit">制程合格率</div>
                </div>

              </div>
            </div>
          </div>
        </div>
      </StrokeTitle>
    </div>
    <div class="content_bottom">
      <StrokeTitle title="近十二个月制程合格率统计" class="float margin" style="width: 49%" :isCenter="true">
        <MoreColBar2 :data="process" :xAxisLine="true" :yAxisLine="true" :axisLabel="false"/>

      </StrokeTitle>
      <StrokeTitle title="近十二个月投诉统计" class="float margin" style="width: 49%" :isCenter="true">
        <MoreColBar2 :data="bottom" :xAxisLine="true" :yAxisLine="true" :axisLabel="false"/>
        <!-- <MoreDirection :data="bottom" :minInterval="null" :legendData="['']" barWidth="21" style="height: 118%;margin-top:-4%" :isCategory="false" :yAxisLineShow="true" :xAxisLineShow="true" :isUnit="true" yUnit="单位：%" gridRight="8%" gridLeft="8%" /> -->
      </StrokeTitle>
    </div>
    <div class="content_bottom">
      <StrokeTitle2 title="不合格项统计分析" class="float margin" style="width: 99%">
        <div class="flex_center" slot="select">
          <!-- <ElementRadio v-model="model2" :isButton="true" @change="radioChange3" /> -->
          <el-date-picker @change="select3" style="width:180px" :editable="false" clearable size="small" v-model="top3Form.rq" type="month" value-format="yyyy-MM" placeholder="选择统计时间">
          </el-date-picker>
          <div slot="select" class="more" @click="$router.push('/report/seven/unstand')" style="margin-left:20px" v-show="unstandList.length>0"> 查看更多不合格项</div>
        </div>
        <div class="flex_center Echarts" style="height:100%" slot="content">
          <el-table v-loading="loading" :data="unstandList">
            <el-table-column label="日期" align="center" prop="rq" width="180" />
            <el-table-column label="类别" align="center" prop="type1" />
            <el-table-column label="产品" align="center" prop="ggname" />
            <el-table-column label="内控" align="center" prop="internalControl" />
            <el-table-column label="实际" align="center" prop="actualValue" />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
              <template slot-scope="scope">
                <div @click="handleView(scope.row)" style="color:#21bbf6;cursor: pointer;">查看</div>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </StrokeTitle2>
    </div>
    <!-- 添加或修改不达标项对话框 -->
    <el-dialog fullscreen :title="title" :visible.sync="open" width="900px" append-to-body>
      <el-form ref="form" :model="form" label-width="90px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="类别" prop="type1">
              <!-- <el-input
                v-model="form.type1"
                placeholder="请输入类别(原物料、水、电)"
                :disabled="openDisabled"
              /> -->
              <el-select v-model="form.type1" placeholder="请选择类别" :disabled="openDisabled">
                <el-option value="原物料消耗率">原物料消耗率</el-option>
                <el-option value="水利用率">水利用率</el-option>
                <el-option value="吨耗电">吨耗电</el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="产品" prop="ggname">
              <el-select v-model="form.ggname" placeholder="请选择" @change="ggchangefun($event)" :disabled="openDisabled">
                <el-option-group v-for="group in options" :key="group.label" :label="group.label">
                  <el-option v-for="item in group.options" :key="item.dictValue" :label="item.dictLabel" :value="{ value:item.dictValue,label:item.dictLabel  }">
                  </el-option>
                </el-option-group>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="产品" prop="gg" v-show="false">
              <el-input v-model="form.gg" placeholder="请输入产品" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="所属工厂" prop="factoryId">
              <el-select v-model="form.factoryId" placeholder="请选择所属工厂" clearable size="small" :disabled="true">
                <el-option v-for="dict in factoryListOptions" :key="dict.deptId" :label="dict.name" :value="dict.deptId"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="日期" prop="rq">
              <el-date-picker :editable="false" clearable size="small" v-model="form.rq" type="date" value-format="yyyy-MM-dd" placeholder="选择日期" :disabled="openDisabled">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="内控指标值" prop="internalControl">
              <el-input v-model="form.internalControl" placeholder="请输入内控指标" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际指标值" prop="actualValue">
              <el-input v-model="form.actualValue" placeholder="请输入实际指标" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="原因" prop="season">
              <el-input v-model="form.season" type="textarea" placeholder="请输入内容" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="措施" prop="measures">
              <el-input v-model="form.measures" type="textarea" placeholder="请输入内容" :disabled="openDisabled" />
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import NormalLine from "@/components/echarts/line/normal.vue";
import { clientComplaint, complaintList } from "@/api/report/complain/complain";
import { processList, clientComplaint2 } from "@/api/report/complain/process";
import MoreColBar2 from "@/components/echarts/bar/moreCol2.vue"; //多个纵向柱状图左右
import StrokeTitle2 from "@/components/myComponents/stroke/title2.vue";
import { getFactoryList } from "@/api/report/complain/complain";
import { listUnstand2, getUnstand } from "@/api/report/complain/unstand";
export default {
  components: {
    NormalLine,
    MoreColBar2,
    StrokeTitle2,
  },
  data() {
    return {
      model: "month",
      selectList: [
        { value: "", label: "全部" },
        { value: "1", label: "选项一" },
      ],
      bzjkImgList: [
        require("@/assets/images/echarts/bar.png"),
        require("@/assets/images/echarts/line.png"),
        require("@/assets/images/echarts/bar.png"),
      ],
      color: ["blue", "orange", "green", "pink"],
      //近十二个月投诉统计
      bottom: { xData: [], yData1: [], yData2: [] },
      //近十二个月制程统计
      process: {
        xData: [],
        yData1: [],
        yData2: [],
      },
      color: ["blue", "orange", "green", "pink", "yellow"],
      // 统计数据
      top: [0, 0, 0, 0, 0],
      top1: [0, 0, 0, 0, 0],
      loading: false,
      // 不达标项表格数据
      unstandList: [],
      // 查询参数
      top3Form: {
        pageNum: 1,
        pageSize: 5,
        rq: null,
        // jsrq: this.$getLastMonth("e"),
        // ksrq: this.$getLastMonth("s"),
      },
      //弹窗是否禁止编辑
      openDisabled: true,
      // 选中数组
      ids: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      // 所属工厂
      factoryListOptions: [],
      options: [],
    };
  },
  mounted() {
    this.getList();
    this.getFactoryList(); //工厂信息
  },
  methods: {
    radioChange() {},
    getList() {
      clientComplaint().then((response) => {
        // console.log(response)
        this.top = response.data;
        this.top[0] = Number(this.top[0]).toFixed(4);
        this.top[1] = Number(this.top[1]).toFixed(4);
        this.top[2] = Number(this.top[2]).toFixed(4);
        this.top[3] = Number(this.top[3]).toFixed(4);
      });
      clientComplaint2().then((response) => {
        // console.log(response)
        this.top1 = response.data;
        this.top1[0] = Number(this.top1[0]).toFixed(2);
        this.top1[1] = Number(this.top1[1]).toFixed(2);
        this.top1[2] = Number(this.top1[2]).toFixed(2);
        this.top1[3] = Number(this.top1[3]).toFixed(2);
      });
      complaintList().then((res) => {
        this.bottom = {
          xData: [],
          yData1: [],
          yData2: [],
        };
        res.data.forEach((item) => {
          this.bottom.xData.push(item.name);
          this.bottom.yData1.push(item.value1);
          this.bottom.yData2.push(item.controlValue);
        });
      });
      processList().then((res) => {
        this.process = {
          xData: [],
          yData1: [],
          yData2: [],
        };
        res.data.forEach((item) => {
          this.process.xData.push(item.name);
          this.process.yData1.push(item.value1);
          this.process.yData2.push(item.controlValue);
        });
      });
    },
    select3() {
      this.getListBottom();
    },
    /** 查询不达标项列表 */
    getListBottom() {
      // alert(1)
      this.loading = true;
      listUnstand2(this.top3Form).then((response) => {
        this.unstandList = response.rows;
        this.loading = false;
      });
    },
    //工厂信息
    getFactoryList() {
      getFactoryList().then((response) => {
        this.factoryListOptions = response.data;
      });
    },
    /** 查看按钮 */
    handleView(row) {
      this.reset();
      this.openDisabled = true;
      const id = row.id || this.ids;
      getUnstand(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "查看不达标项";
      });
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        type1: null,
        gg: null,
        ggname: null,
        rq: null,
        season: null,
        measures: null,
        factoryId: null,
        delFlag: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
      };
      this.resetForm("form");
    },
  },
};
</script>


<style lang="scss" scoped>
.seven_content {
  z-index: 10;
  background: #093b76;
  width: 100%;
  height: calc(100vh - 183px);
  overflow: auto;
  .content_top,
  .content_bottom,
  .content_center {
    //   background: red;
    width: 100%;
    height: 37.8%;
  }
  .content_top {
    // height: 24.6%;
    height: 26.6%;
  }
  .content_bottom {
    // height: 29.9%;
    height: 32.9%;
  }
  .bzjk_box {
    width: 100%;
    height: 150px;
    padding: 8px 1%;
    // max-height: 140px;
    // min-height: 110px;
    // .sjtj_item {
    //   // width: 9.5%;
    //   width: 20.5%;
    //   background: linear-gradient(
    //     180deg,
    //     rgba(14, 81, 141, 0.5) 0%,
    //     rgba(18, 81, 141, 0.5) 100%
    //   );
    //   border: 1px solid #2489ee71;
    //   height: 100%;
    //   padding: 3px;
    //   position: relative;
    //   .title {
    //     font-size: 17px;
    //     width: 100%;
    //     // height: 44%;
    //     height: 50%;
    //     background: rgba(35, 107, 173, 0.6);
    //   }
    //   .number {
    //     font-size: 25px;
    //     width: 100%;
    //     height: 54%;
    //     background: rgba(35, 107, 173, 0.6);
    //     background-image: url("~@/assets/images/echarts/zhuangshi.png");
    //     background-size: 100% 100%;
    //     margin-top: 3%;
    //     font-weight: 700;
    //     .bottom-item{
    //       width: 45%;
    //       height: 100%;
    //     }
    //   }
    // }
    .cntj_item {
      width: 24.5%;
      background: linear-gradient(
        180deg,
        rgba(44, 119, 187, 0.5) 0%,
        rgba(18, 81, 141, 0.5) 100%
      );
      border: 1px solid #2489ee71;
      height: 100%;
      padding: 10px;
      nav {
        font-size: 18px;
        background: rgba(35, 107, 173, 0.7);
        height: 32%;
        width: 100%;
        text-align: center;
      }
      .cntj_item_content {
        width: 100%;
        height: 66%;
        margin-top: 2%;
        .cntj_item_content_item {
          width: 49%;
          background-image: url("~@/assets/images/echarts/zhuangshi.png");
          background-size: 100% 100%;
          height: 100%;
          background-color: rgba(35, 107, 173, 0.7);
          .number {
            font-size: 28px;
          }
          .unit {
            font-size: 13px;
            margin-top: 0.2% !important;
            color: #ffffff;
          }
        }
        .cntj_item_content_item-100 {
          width: 100%;
        }
      }
    }
    .and {
      margin: 0 20px;
      width: 40px;
    }
  }
  .Echarts {
    height: calc(100% - 50px);
  }
  .center_echarts {
    height: 180px;
  }
  .border_blue {
    border-bottom: 3px solid rgba(0, 192, 255, 0.9);
  }
  .border_orange {
    border-bottom: 3px solid rgba(255, 153, 0, 0.9);
  }
  .border_green {
    border-bottom: 3px solid rgba(59, 255, 230, 0.9);
  }
  .border_pink {
    border-bottom: 3px solid rgba(254, 58, 234, 0.9);
  }
  .border_yellow {
    border-bottom: 3px solid rgba(246, 255, 55, 0.9);
  }
  .text_blue {
    color: rgba(0, 192, 255, 0.9);
  }
  .text_orange {
    color: rgba(255, 153, 0, 0.9);
  }
  .text_green {
    color: rgba(59, 255, 230, 0.9);
  }
  .text_pink {
    color: rgba(254, 58, 234, 0.9);
  }
  .text_yellow {
    color: rgba(246, 255, 55, 0.9);
  }
  .text_shadow_blue {
    color: rgba(0, 192, 255, 0.9);
    text-shadow: 1px 0px 3px rgba(0, 192, 255, 1);
  }
  .text_shadow_orange {
    color: rgba(255, 153, 0, 0.9);
    text-shadow: 1px 0px 3px rgba(255, 153, 0, 1);
  }
  .text_shadow_green {
    color: rgba(59, 255, 230, 0.9);
    text-shadow: 1px 0px 3px rgba(59, 255, 230, 1);
  }
  .text_shadow_pink {
    color: rgba(254, 58, 234, 0.9);
    text-shadow: 1px 0px 3px rgba(254, 58, 234, 1);
  }
  .text_yellow {
    color: rgba(246, 255, 55, 0.9);
    text-shadow: 1px 0px 3px rgba(246, 255, 55, 0.9);
  }
}
</style>
